Skip to content

gh-141510: Implement copy and deepcopy for frozendict#144905

Open
eendebakpt wants to merge 9 commits intopython:mainfrom
eendebakpt:copy_module_frozendict
Open

gh-141510: Implement copy and deepcopy for frozendict#144905
eendebakpt wants to merge 9 commits intopython:mainfrom
eendebakpt:copy_module_frozendict

Conversation

@eendebakpt
Copy link
Contributor

@eendebakpt eendebakpt commented Feb 17, 2026

@eendebakpt eendebakpt changed the title gh-41510: Implement copy and deepcopy for frozendict gh-141510: Implement copy and deepcopy for frozendict Feb 17, 2026
@eendebakpt eendebakpt marked this pull request as draft February 17, 2026 11:37
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it a draft PR?

Changes cherry-picked from #141508 by @vstinner

I'm surprised that you created a PR from my WIP work. I'm currently splitting this big PR into smaller pieces, as I wrote in the PR.

@eendebakpt
Copy link
Contributor Author

eendebakpt commented Feb 17, 2026

Draft because there are failing tests are due to making _deepcopy_dispatch immutable. The failing test is a bit strange, see

# This is an ugly hack:

I will look into this.

eendebakpt and others added 4 commits February 17, 2026 21:28
@eendebakpt
Copy link
Contributor Author

eendebakpt commented Feb 17, 2026

I'm surprised that you created a PR from my WIP work. I'm currently splitting this big PR into smaller pieces, as I wrote in the PR.

Sorry, my mistake. Feel free to close the PR if it is interfering.

Lib/copy.py Outdated
return type(x)(x.__func__, deepcopy(x.__self__, memo))
d[types.MethodType] = _deepcopy_method

_deepcopy_dispatch = frozendict(d)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to not convert it to a frozendict in this PR, since it's not directly related to supporting frozendict in copy: remove this line and revert test_descr changes.

Copy link
Contributor Author

@eendebakpt eendebakpt Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it here. Do you want me to open a separate PR for this part?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote #144909 to use frozendict in multiple stdlib modules. I will to see how this PR goes before proposing changing copy._deepcopy_dispatch to frozendict.

@eendebakpt eendebakpt marked this pull request as ready for review February 17, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants